import math
import numpy as np
import matplotlib.pyplot as plt


def fx(x):
    return 4.0/(1.0+pow(x,2))


def SimpInt1(a, b, n_node):
    n = 2*n_node + 1
    h = (b-a)/(n-1)
    x= []
    for i in range(n):
        x.append(a + i * h)
    y = []
    for i in x:
        y.append(fx(i))
    y2 = 0.00
    for i in range(n-1):
        if i >0:
            if i%2==1:
                y2 =y2 + y[i]
    y3 = 0.00
    for i in range(n-2):
        if i >1:
            if i%2==0:
                y3 = y3 + y[i]
    S = (h/3)*(y[0]+4*y2+2*y3+y[n-1])
    return S
print(SimpInt1(0,1,100))